package logic

import (
	"context"
	"manage/models/mysql"

	"manage/managerpc/internal/svc"
	"manage/managerpc/managerpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type RateAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewRateAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RateAddLogic {
	return &RateAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *RateAddLogic) RateAdd(in *managerpc.RateAddRequest) (*managerpc.RateAddResponse, error) {
	// todo: add your logic here and delete this line

	manage := mysql.Rate{
		UserId:  in.UserId,
		RateId:  in.RateId,
		Context: in.Context,
	}
	mysql.DB.Create(&manage)
	return &managerpc.RateAddResponse{
		RateId: in.RateId,
	}, nil
}
